program q1004;
var
    n, i, j, color_cnt, ans, max, hit: integer;
    colors: array[1..1000] of string;
    cnt: array[1..1000] of integer;
    s:string;
begin
    assign(input, '');
    assign(output, '');
    reset(input);
    rewrite(output);

    while not eof do
        begin
        readln(n);
        if (n = 0) then break;
        fillchar(cnt, sizeof(cnt), 0);
        fillchar(colors, sizeof(colors), 0);

        color_cnt := 0;
        for i:=1 to n do
            begin
            readln(s);
            hit := 0;
            for j:=1 to color_cnt do
                begin
                if (colors[j] = s) then
                    begin
                    inc(cnt[j]);
                    hit := 1;
                    end;
                end;
            end;

            if (hit = 0) then
                begin
                colors[color_cnt+1] := s;
                inc(cnt[color_cnt+1]);
                inc(color_cnt);
                end;

            max := 0;
            for i:=1 to color_cnt do
                begin
                if (cnt[i] > max) then
                    begin
                    max := cnt[i];
                    ans := i;
                    end;
                end;

            writeln(colors[ans]);
        end;

    close(input);
    close(output);
end.
